updating oE checksum

checksum

include filesys.e 
namespace filesys 
public function checksum(sequence filename, integer size = 4, integer usename = 0, 
        integer return_text = 0) 

returns a checksum value for the specified file.

Parameters:
  1. filename : A sequence. The name of the file whose checksum you want.
  2. size : An integer. The number of atoms to return. Default is 4
  3. usename: An integer. If not zero then the actual text of filename will affect the resulting checksum. The default (0) will not use the name of the file.
  4. return_text: An integer. If not zero, the check sum is returned as a text string of hexadecimal digits otherwise (the default) the check sum is returned as a sequence of size atoms.
Returns:

A sequence containing size atoms.

Comments:
  • The larger the size value, the more unique will the checksum be. For most files and uses, a single atom will be sufficient as this gives a 32-bit file signature. However, if you require better proof that the content of two files are different then use higher values for size. For example, size = 8 gives you 256 bits of file signature.
  • If size is zero or negative, an empty sequence is returned.
  • All files of zero length will return the same checksum value when usename is zero.
Example 1:
 -- Example values. The exact values depend on the contents of the file. 
 include std/console.e 
 display( checksum("myfile", 1) ) --> {92837498} 
 display( checksum("myfile", 2) ) --> {1238176, 87192873} 
 display( checksum("myfile", 2,,1)) --> "0012E480 05327529" 
 display( checksum("myfile", 4) ) --> {23448, 239807, 79283749, 427370} 
 display( checksum("myfile") )    --> {23448, 239807, 79283749, 427370} -- default 
Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu